<!DOCTYPE html>
<html>
<head>
	<title>图书列表</title>
	<base href="http://localhost/">
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css">
	<script type="text/javascript" src="layui/layui.js"></script>
	<style>
		.header span{background:#009688;margin-left: 0px;padding: 10px;color:#ffffff;}
		#but{float:right;}
		.page{float: right;}
		.page li{
			float:left;
			background:#009688;
			height: 25px;width: 45px; 
			margin: 0 1px;text-align: 
			center;line-height: 25px;
			border-radius:2px;
		}
		.page li a{
			width: 45px;
			display: inline-block;
			color: white;
		}
		.page li:hover a{
			font-weight: bold;
		} 
		.active{
			color: white;
			background: red!important;
		}
		.layui-container{
			width: 1300px;
		}
	</style>
</head>
<body style="padding: 10px;">
	<div class="layui-container">
	<hr class="layui-bg-green">
	<div class="header">
		<span>图书列表</span>
		<form class="layui-form layui-input-inline" action="index.php/Admbooks/book_query" method="POST">
				<div class="layui-input-inline">
		      	<input type="text" name="queryname" class="layui-input" id="queryname" placeholder="请输入查询书名">
		    	</div>
		    	<button class="layui-btn" onclick="return checkname(form)">查询</button>	
		</form>
		<button id="but" class="layui-btn" onclick="add()">添加</button>
	</div>

	<table class="layui-table">
		<thead>
			<tr>
				<th>ID</th>
				<th>图书编号</th>
				<th>图书类别</th>
				<th>书名</th>
				<th>作者</th>
				<th>出版社</th>
				<th>图书总数</th>
				<th>图书库存</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($data as $value): ?>
				<tr>
					<th><?= $value["Book_ID"]?></th>
					<th><?= $value["ISBN"]?></th>
					<th><?= $value["Type"]?></th>
					<th><?= $value["Title"]?></th>
					<th><?= $value["Author"]?></th>
					<th><?= $value["Publisher"]?></th>
					<th><?= $value["Number"]?></th>
					<th><?= $value["Stocks"]?></th>
					<td>
					<bytton class="layui-btn layui-btn-xs" onclick="edit(<?= $value["Book_ID"]?>)">编辑</bytton>
					<bytton class="layui-btn layui-btn-xs layui-btn-danger"><a href="index.php/Admbooks/book_dele?id=<?= $value['Book_ID']?>" style='color:white;'>删除</a></bytton>
				</td>
				</tr>
			<?php endforeach ;?>
		
		</tbody>
	</table>
	<?php
	if(isset($links))
	 	echo $links;
	?>
	</div>
	<!-- echo $links  -->
<script type="text/javascript">
	layui.use('layer',function(){
		layer = layui.layer;
		$ = laui.jquery;
	})
	//添加图书 
	function add(){
		var mylay=layer.open({
			  type: 2,
			  title:'添加用户',
			  shadeClose: true,
			  shade: 0.3,
			  area: ['500px', '500px'],
			  content: 'index.php/Admbooks/add', //iframe的url
			  end: function() {
                //子页面提交完 刷新页面, 
				location.reload();
				},
			});
	}
	//编辑图书
	function edit(id){
		var editlay=layer.open({
			  type: 2,
			  title: '编辑用户',
			  shadeClose: true,
			  shade: 0.3,
			  area: ['500px', '500px'],
			  content: 'index.php/Admbooks/book_edit?id='+id, //iframe的url
			  end: function() {
                //子页面提交完 刷新页面, 
				location.reload();
				},
			});
	}
	//模糊查询图书
	function checkname(form){
		if(form.queryname.value==""){
			alert("请输入查询的关键字");
			form.queryname.focus();
			return false;
		}
		form.submit();
	}
	//删除弹出模态框
	// function deleuser(id){
	// 	$id = id;
	// 	layer.confirm('确定要删除吗？', {
	// 		btn: ['确定','取消']
	// 		}, function(){
	// 		// $("#deleid").attr("href","/index.php/Main/user_dele?id=$id");			
	// 		layer.msg("删除成功");
	// 		});
	// }

</script>
</body>
</html>